#if defined( DUAL_CORE )
#include <windows.h>
#endif
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include <math.h>

#include "Nasha.h"

typedef HashReturn (*f)(int, const BitSequence*, DataLength, BitSequence*);
typedef struct{
	hashState hs;
	f fh;
}hash_ctx;

unsigned int rand32(void)
{   static unsigned int   r4,r_cnt = -1,w = 521288629,z = 362436069;

    z = 36969 * (z & 65535) + (z >> 16);
    w = 18000 * (w & 65535) + (w >> 16);

    r_cnt = 0; r4 = (z << 16) + w; return r4;
}

unsigned char rand8(void)
{   static unsigned int   r4,r_cnt = 4;

    if(r_cnt == 4)
    {
        r4 = rand32(); r_cnt = 0;
    }

    return (char)(r4 >> (8 * r_cnt++));
}

// fill a block with random charactrers

void block_rndfill(unsigned char l[], unsigned int len)
{   unsigned int  i;

    for(i = 0; i < len; ++i)

        l[i] = rand8();
}

void block_fill0(unsigned char l[], unsigned int len)
{   unsigned int  i;

    for(i = 0; i < len; ++i)

        l[i] = 0;
}

unsigned char   buf[125000];

int mainAS(void)
{   int i,j, hashl,dlen;

	hash_ctx  hc[1];
    BitSequence  hv[64];

	block_fill0(buf, 125000);
	printf("Vnesi dolzina vo bitovi -> ");
    scanf("%d",&j);
	printf("Vnesi dolzina na hashot -> ");
    scanf("%d",&hashl);
	if (hashl==256)
		dlen=32;
	else if (hashl==224)
		dlen=28;
	else if (hashl==384)
		dlen=48;
	else dlen=64;
	hc->fh=Hash;
	hc->fh(hashl, buf, j, hv);
	printf("\n");
	for(i=0;i<dlen;i++)
		printf("%X ", hv[i]);
	return 0;
}
